package com.tuozixuan.camel;

import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.support.processor.DefaultExchangeFormatter;
import org.springframework.stereotype.Component;

@Component("logFormatter")
public class MyCustomFormatter extends DefaultExchangeFormatter {

	@Override
	public String format(Exchange exchange) {
		
		Message message = exchange.getIn();
		Object object = message.getBody();
		if (object instanceof GenericFile) {
			// 如果是文件，则在日志中输入内容
			return message.getBody(String.class);
		} else {
			// 其它，则使用默认的格式化
			return super.format(exchange);
		}
	}

}
